<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
	<title>Shoping List</title>
</head>
<body>
	<h1>What to buy</h1>
	<p id="reminder" title="a gentle reminder">Don't forget to buy this stuff.</p>
	<ul id="purchases">
		<li>A tin of beans</li>
		<li>Cheese</li>
		<li>Milk</li>
	</ul>
	<p>This is juse a test.</p>
	<script type="text/javascript">
	//alert(typeof document.getElementById("purchase"));
	//alert(document.getElementsByTagName("li").length);
	var items = document.getElementsByTagName("li");
	for (var i=0; i < items.length; i++){
		alert(items[i].textContent);
	}
	alert(document.getElementById("reminder").textContent);
	//alert(document.getElementById("reminder").getAttribute("title"));
	// var paras = document.getElementsByTagName("p");
	// for (var i=0; i < paras.length; i++){
	// 	alert(paras[i].getAttribute("title"));//获取元素的属性的值
	// }
	var paras = document.getElementsByTagName("p");
	for (var i=0; i<paras.length; i++){
		var title_text = paras[i].getAttribute("title");
		if(title_text)
		{
			alert(title_text);
		}else{
			alert("This tag has no title!");
		}
	}
	var shopping = document.getElementById("purchases");
	alert(shopping.getAttribute('title'));
	shopping.setAttribute('title', 'a list of goods');
	alert(shopping.getAttribute('title'));
	</script>
</body>
</html>